package dao

import (
	"common/logs"
	"context"
	"core/models/entity"
	"core/repo"
)

type GameDao struct {
	repo *repo.Manager
}

func NewGameDao(m *repo.Manager) *GameDao {
	return &GameDao{
		repo: m,
	}
}

func (d GameDao) SaveEventLog(ctx context.Context, ac *entity.EventLog) error {
	tb := ac.TableName()
	if len(tb) == 0 {
		logs.Error("TableName undefined ，entity.EventLog")
	}
	table := d.repo.Mongo.Db.Collection(tb)
	_, err := table.InsertOne(ctx, ac)
	if err != nil {
		return err
	}
	return nil
}
